#include <stdio.h>
#include <math.h>

int main(void) {
    int a;
    double b;
    scanf("%d %lf", &a, &b);
    
    int c = (int)(b / 24);
    double d = fmod(b, 24.0);
    double e = 0.0, f = 0.0;
    
    if(a == 1) {
        f = 50.0;
        if(d <= 1.0) {
            e = 5.0;
        } else {
            e = 5.0 + ceil((d - 1.0) / 0.5) * 2.0;
        }
    } else if(a == 2) {
        f = 30.0;
        if(d <= 2.0) {
            e = 5.0;
        } else {
            e = 5.0 + ceil(d - 2.0) * 2.0;
        }
    } else if(a == 3) {
        f = 20.0;
        if(d <= 3.0) {
            e = 5.0;
        } else {
            e = 5.0 + ceil(d - 3.0) * 1.0;
        }
    }
    
    if(e > f) {
        e = f;
    }
    
    double ans = c * f + e;
    
    printf("%.2f", ans);
    return 0;
}
